<template>
    <!-- 修改资料 -->

    <div>
        <!-- 内容主题区域 -->
        <el-form label-width="100px" :model="form" label-position="right" ref="formRef" :rules="formRules" disabled
            class="borderNone">
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="编号" prop="number">
                        <el-input v-model="form.number"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="名称" prop="name">
                        <el-input v-model="form.name"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="18" :md="18" :lg="18" :xl="18">
                    <el-form-item label="类别" prop="codeKindName">
                        <el-input v-model="form.codeKindName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="6" :md="6" :lg="6" :xl="6">
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="自定义1" prop="customer1">
                        <el-input v-model="form.customer1"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="自定义2" prop="customer2">
                        <el-input v-model="form.customer2"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="自定义3" prop="customer3">
                        <el-input v-model="form.customer3"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="自定义4" prop="customer4">
                        <el-input v-model="form.customer4"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="备注">
                        <el-input v-model="form.remark"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="状态" prop="status">
                        <el-switch v-model="form.status" size="large" inline-prompt :active-icon="Check"
                            :inactive-icon="Close" active-value="normal" inactive-value="disable" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="文件类型">
                        <el-input v-model="form.fileKindName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                    <el-form-item label="另存为文件名">
                        <el-input v-model="form.saveToFileName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label="上传附件" prop="file">
                <tsImage v-if="checkImgType(form.fileName)" :imageUrl="imageUrl"></tsImage>
                <video v-else-if="checkVideoType(form.fileName)" :src="imageUrl" controls
                    style="width: 20%;height: 100%;"></video>
                <span v-else>{{ form.fileName }}</span>
            </el-form-item>
        </el-form>
        <div class="button-position">
            <el-button @click="updateVisible" type="primary">退 出</el-button>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { ElNotification, ElSwitch, ElForm, ElButton, ElInput, ElFormItem, ElTreeSelect } from 'element-plus';
import { Check, Close } from '@element-plus/icons-vue';
import tsImage from '@/components/tsImage/index.vue'
import Api from '@/api/model/system'
const emit = defineEmits(['updatetable'])
const imageUrl = ref()
const props = defineProps({
    paramsData: {
        type: Object,
        defalut: {}
    }
})
const form = ref({});
onMounted(() => {
    getData()

})


const updateVisible = () => {
    emit('updatetable')
}
const checkImgType = (row) => {
    if (!/\.(jpg|jpeg|png|GIF|JPG|PNG)$/.test(row)) {
        return false;
    } else {
        return true;
    }
}
const checkVideoType = (row) => {
    console.log(row)
    if (!/\.(mp4|mov|avi|flv|qt)$/.test(row)) {
        return false;
    } else {
        return true;
    }
}

//调取数据
const getData = async () => {
    let res = await Api.resourcefile.detail.post(props.paramsData);
    console.log(res)
    if (res.code == 200) {
        form.value = res.data;
        imageUrl.value = res.data.fileFullPath
    } else {
        form.value = '';
    }

}


</script>

<style lang="less" scoped>
.borderNone {
    :deep(.el-input__wrapper) {
        box-shadow: 0 0 0 0px var(--el-input-border-color, var(--el-border-color)) inset;
        cursor: default;
        background-color: transparent; //背景颜色透明
        border-bottom: 1px solid #999;
        border-radius: 0;

        .el-input__inner {
            cursor: default !important;
        }
    }
}
</style>

